﻿using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Linq;
using System.Text;
using System.Windows.Forms;

namespace MidasPoster
{
    public partial class QuestionForm : AuthFormBase
    {
        public QuestionForm()
        {
            InitializeComponent();
            Title = this.Text;
        }

        private void QuestionForm_FormClosed(object sender, FormClosedEventArgs e)
        {
            
        }

        private void QuestionForm_FormClosing(object sender, FormClosingEventArgs e)
        {
            //e.Cancel = true;
            //this.Visible = false;
        }
        public void SetData(MDTB_QUESTION _data)
        {
            MP_QS_PropertyGrid.SelectedObject = _data;
            MP_QS_PropertyGrid.Update();
            UpdateTitle();
        }
        private void QuestionForm_Load(object sender, EventArgs e)
        {
//             MDTB_QUESTION _question = new MDTB_QUESTION();
//             _question.QUESTIONDESC = "问题是你不会";
//             _question.USERID_ASK = "匿名";
// 
//             MP_QS_PropertyGrid.SelectedObject = _question;

            //base.AuthFormBase_Load(sender, e);
        }

        private void MP_QUESTION_CLOSE_BUTTON_Click(object sender, EventArgs e)
        {
            if (MessageBox.Show("Do you want to close this Form?", "Confirm Message", MessageBoxButtons.OKCancel,MessageBoxIcon.Question) == DialogResult.OK)
            {
                Close();
            }
        }

        private void MP_QUESTION_SAVE_BUTTON_Click(object sender, EventArgs e)
        {
            if (MessageBox.Show("Do you want to save this Item?", "Confirm Message", MessageBoxButtons.OKCancel, MessageBoxIcon.Question) == DialogResult.OK)
            {
                //delete
                MDTB_QUESTION _question = (MDTB_QUESTION)MP_QS_PropertyGrid.SelectedObject;
                DBManager.Singleton.InsertQuestionItem(ref _question);
                MP_QS_PropertyGrid.SelectedObject = _question;
                MP_QS_PropertyGrid.Update();
            }
        }

        private void MP_QUESTION_DELETE_BUTTON_Click(object sender, EventArgs e)
        {
            
            if (MessageBox.Show("Do you want to delete this Item?", "Confirm Message", MessageBoxButtons.OKCancel, MessageBoxIcon.Question) == DialogResult.OK)
            {
                //delete
            }
        }
    }
}
